/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jigdo.data.template.section.DESCEntries;

import jigdo.data.template.section.*;

/**
 * Base class inherited by all description entry types for template files.
 * @author John R Sohn
 */
public abstract class TemplateDESCEntry {
    
    
    public TemplateSection Parent;
    public int OrdinalPosition;
    
    public boolean IsRawData()
    {
        return TemplateDESCRawDataEntry.class.isInstance(this);
    }
    
    public boolean IsImageInfo()
    {
        return TemplateDESCImageInfoEntry.class.isInstance(this);
    }
    
    public boolean IsFileEntry()
    {
        return TemplateDESCFileInfoEntry.class.isInstance(this);
    }
    
    /**
     * The byte position where the section of the iso this entry represents begins, if applicable
     */
    public long FileOffset;
    
    /**
     * The size in the file that this entry represents, if applicable. In bytes.
     */
    public long DataSize;
    
    public TemplateDESCEntry(TemplateSection parent, int ordinalPos, long LastOffset)
    {
        Parent = parent;
        OrdinalPosition = ordinalPos;
        FileOffset = LastOffset;
    }
    
    
    /**
     * Retrieves the entry from the byte array and returns the new start index
     * @param data the byte[] to retrieve the entry from
     * @param startindex the index at which to start retrieving the data
     * @return The new startindex in the byte array1
     */
    public int ReadEntry(byte[] data, int startindex)
    {
        return 0;
    }
    
    /**
     * Represents the DESC section entry type
     */
    public enum EntryType { 
        /**
         * Information about the iso image itself
         */
        ImageInfo, 
        /**
         *  Information about a raw data section: DATA or BZIP
         */
        RawInfo, 
        /**
         *  Information about specific file entries.
         */
        FileInfo
    }
    
}
